package com.bocai.eelly.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bocai.eelly.R;

import java.util.List;


public class DialogAdapter extends BaseAdapter
{
    private Context context;
    private List<String> titles;
    public DialogAdapter(Context context, List<String> titles)
    {
        this.context=context;
        this.titles=titles;
    }

    @Override
    public int getCount()
    {
        return titles.size();
    }

    @Override
    public Object getItem(int position)
    {
        return titles.get(position);
    }

    @Override
    public long getItemId(int position)
    {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent)
    {
        ViewHolder viewHolder ;
        if (convertView == null)
        {
            viewHolder = new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.dialog_item,null);
            viewHolder.tv_popwindow_item=(TextView)convertView.findViewById(R.id.tv_popwindow_item);
            convertView.setTag(viewHolder);
        } else
        {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tv_popwindow_item.setText(titles.get(position));
        return convertView;
    }


    public class ViewHolder
    {
        TextView tv_popwindow_item;
    }
}
